﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace ORM_EF
{
    public class DbInitialize:System.Data.Entity.DropCreateDatabaseAlways<CodeFirstContext>
    {
        protected override void Seed(CodeFirstContext context)
        {
            User user = new User();
            user.Id = 1;
            user.Name = "wang";
            User user1 = new User { Id = 2, Name = "sb" };

            Card card = new Card();
            card.Id = 1;
            card.CardName = "xianhui";
            //将实体赋予给上下文，并添加到表里
            context.User.Add(user);
            context.User.Add(user1);
            context.Card.Add(card);
            //保存
            context.SaveChanges();

            base.Seed(context);
        }
    }
}
